package qunchat;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Method  {
	private Socket s;
	private String name;
	private String msg;
	public Method(Socket s,String name) {
		this.s=s;
		this.name=name;
	}
	public void sendMsg(String msg) throws IOException{
		ObjectOutputStream oos=new ObjectOutputStream(s.getOutputStream());
		oos.writeObject(name+":"+msg);
		oos.flush();
	}
	public void transMsg() throws IOException{
		Scanner sc=new Scanner(System.in);
		String send=sc.nextLine();
		while(!send.equals("bye")){
			sendMsg(send);
			send=sc.nextLine();
		}
		sc.close();
		System.out.println(name+"退出聊天");
		s.close();
	}
}
